package gist.thread_pool;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 通过java.util.concurrent包中的Executors类可以创建线程对象,即创建线程类ExecutorService的实例。
 * 
 * @author gss
 * 
 */
public class ThreadPoolTest {
	public static void main(String[] args) {
		ExecutorService executorService = Executors.newFixedThreadPool(5);// 创建线程池对象
		// 为线程池对象的submit（）方法传递Runnable接口实现类ShowInfoThread的实例
		executorService.submit(new ShowInfoThread());
		// 为线程池对象的submit（）方法传递Runnable接口实现类PrintInfoThread的实例
		executorService.submit(new PrintInfoThread());
		executorService.shutdown();// 所有线程池执行完毕关闭线程池对象
	}
}
